# -*- coding: utf-8 -*-
# @Author : zhaochen
# @Date   : 2019/8/5
# @File   : EC10_DataIsNull.py
# @E-mail : zhaochen@bbdservice.com


'''eof
name:企业征信数据是否异常
code:EC10_DataIsNull
tableName:
columnName:
groups:企业征信模块
dependencies:EC_DSJ
type:常用指标
dataSourceType:在线指标
description:
eof'''

import sys
import re


reload(sys)
sys.setdefaultencoding('utf-8')

null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']

def getTable(table_Name):
    try:
        data = EC_DSJ['data'].get(table_Name)
        if data in null_type_list:
            return None
        else:
            if isinstance(data, list):
                return data
            else:
                return None
    except:
        return None


def EC10_DataIsNull():
    '''判断ECRSummaryDesc 表中 ReportNo  是否缺失'''
    try:
        ECRSummaryDesc = getTable('ECRSummaryDesc')
        if ECRSummaryDesc is None:
            raise Exception(u'企业征信数据ReportNo不存在')
        else:
            if ECRSummaryDesc[0].get('ReportNo') in null_type_list:
                raise Exception(u'企业征信数据ReportNo不存在')
            else:
                return 0
    except:
        raise Exception(u'企业征信数据ReportNo不存在')


result = EC10_DataIsNull()
